Detailed example counts for week of 2018-12-03 across
type and direction.
Overview of months, cyclists, outbound
Frequency of net from whole period
Frequency of stocks from whole period
Detailed example counts for week of 2018-12-09 across
type of data.
Overview of months, connected users
Frequency of counts from whole period
# ####
# Jeffreys prior
a1 <- 5e-5
b1 <- 5e-5
lgprior1 <- list(prec = list(param = c(a1, b1)))
# Gelman prior
a2 <- -0.5
b2 <- 5e-5
lgprior2 <- list(prec = list(param = c(a2, b2)))
# iid prior
# Schrödle & Held 2010 & Blangiardo et al 2013
a0 <- 1
b0 <- 0.1
prior.nu <- list(prec = list(param = c(a0, b0)))
# intercept & fixed
inla.set.control.fixed.default()
# intercept ~ N(0,0)
# other fixed effects ~ N(0, 0.001)
#
# where the format is N(mean, precision)
# precision = inverse of the variance.
# PC prior
U <- 1
hyper.prec = list(theta = list(
prior = "pc.prec",
param = c(U, 0.01)
))
# scaling
inla.setOption(scale.model.default = TRUE)mod1 <- inla(users_mac ~
f(stock, model = "rw1", scale.model = TRUE, hyper = hyper.prec),
family = "nbinomial",
control.compute = list(dic= TRUE, waic = TRUE),
data = data)
Call:
c("inla.core(formula = formula, family = family, contrasts = contrasts,
", " data = data, quantiles = quantiles, E = E, offset = offset, ", "
scale = scale, weights = weights, Ntrials = Ntrials, strata = strata,
", " lp.scale = lp.scale, link.covariates = link.covariates, verbose =
verbose, ", " lincomb = lincomb, selection = selection, control.compute
= control.compute, ", " control.predictor = control.predictor,
control.family = control.family, ", " control.inla = control.inla,
control.fixed = control.fixed, ", " control.mode = control.mode,
control.expert = control.expert, ", " control.hazard = control.hazard,
control.lincomb = control.lincomb, ", " control.update =
control.update, control.lp.scale = control.lp.scale, ", "
control.pardiso = control.pardiso, only.hyperparam = only.hyperparam,
", " inla.call = inla.call, inla.arg = inla.arg, num.threads =
num.threads, ", " blas.num.threads = blas.num.threads, keep = keep,
working.directory = working.directory, ", " silent = silent, inla.mode
= inla.mode, safe = FALSE, debug = debug, ", " .parent.frame =
.parent.frame)")
Time used:
Pre = 0.663, Running = 5.36, Post = 0.24, Total = 6.26
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 7.823 0.008 7.806 7.823 7.839 7.822 0
Random effects:
Name Model
stock RW1 model
Model hyperparameters:
mean sd 0.025quant
size for the nbinomial observations (1/overdispersion) 5.21 0.100 5.02
Precision for stock 2.33 0.353 1.73
0.5quant 0.975quant mode
size for the nbinomial observations (1/overdispersion) 5.21 5.41 5.21
Precision for stock 2.30 3.11 2.24
Deviance Information Criterion (DIC) ...............: 81065.63
Deviance Information Criterion (DIC, saturated) ....: 155235.61
Effective number of parameters .....................: 119.67
Watanabe-Akaike information criterion (WAIC) ...: 81078.70
Effective number of parameters .................: 127.84
Marginal log-Likelihood: -42295.32
is computed
Posterior summaries for the linear predictor and the fitted values are computed
(Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
mod2 <- inla(users_mac ~
weekday +
f(stock, model = "rw1", scale.model = TRUE, hyper = hyper.prec),
family = "nbinomial",
control.compute = list(dic= TRUE, waic = TRUE),
data = data)
Call:
c("inla.core(formula = formula, family = family, contrasts = contrasts,
", " data = data, quantiles = quantiles, E = E, offset = offset, ", "
scale = scale, weights = weights, Ntrials = Ntrials, strata = strata,
", " lp.scale = lp.scale, link.covariates = link.covariates, verbose =
verbose, ", " lincomb = lincomb, selection = selection, control.compute
= control.compute, ", " control.predictor = control.predictor,
control.family = control.family, ", " control.inla = control.inla,
control.fixed = control.fixed, ", " control.mode = control.mode,
control.expert = control.expert, ", " control.hazard = control.hazard,
control.lincomb = control.lincomb, ", " control.update =
control.update, control.lp.scale = control.lp.scale, ", "
control.pardiso = control.pardiso, only.hyperparam = only.hyperparam,
", " inla.call = inla.call, inla.arg = inla.arg, num.threads =
num.threads, ", " blas.num.threads = blas.num.threads, keep = keep,
working.directory = working.directory, ", " silent = silent, inla.mode
= inla.mode, safe = FALSE, debug = debug, ", " .parent.frame =
.parent.frame)")
Time used:
Pre = 0.533, Running = 5.61, Post = 0.237, Total = 6.38
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 7.851 0.017 7.818 7.851 7.884 7.851 0
weekdayMonday -0.061 0.023 -0.106 -0.061 -0.015 -0.061 0
weekdaySaturday -0.073 0.025 -0.122 -0.073 -0.025 -0.073 0
weekdaySunday -0.076 0.025 -0.124 -0.076 -0.027 -0.076 0
weekdayThursday 0.025 0.023 -0.020 0.025 0.071 0.025 0
weekdayTuesday -0.019 0.023 -0.065 -0.019 0.027 -0.019 0
weekdayWednesday -0.053 0.023 -0.098 -0.053 -0.008 -0.053 0
Random effects:
Name Model
stock RW1 model
Model hyperparameters:
mean sd 0.025quant
size for the nbinomial observations (1/overdispersion) 5.23 0.100 5.04
Precision for stock 2.36 0.357 1.75
0.5quant 0.975quant mode
size for the nbinomial observations (1/overdispersion) 5.23 5.43 5.23
Precision for stock 2.33 3.14 2.26
Deviance Information Criterion (DIC) ...............: 81047.47
Deviance Information Criterion (DIC, saturated) ....: 155217.45
Effective number of parameters .....................: 125.26
Watanabe-Akaike information criterion (WAIC) ...: 81064.40
Effective number of parameters .................: 136.69
Marginal log-Likelihood: -42324.36
is computed
Posterior summaries for the linear predictor and the fitted values are computed
(Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
mod3 <- inla(users_mac ~
weekend +
weekday +
f(stock, model = "rw1", scale.model = TRUE, hyper = hyper.prec),
family = "nbinomial",
control.compute = list(dic= TRUE, waic = TRUE),
data = data)
Call:
c("inla.core(formula = formula, family = family, contrasts = contrasts,
", " data = data, quantiles = quantiles, E = E, offset = offset, ", "
scale = scale, weights = weights, Ntrials = Ntrials, strata = strata,
", " lp.scale = lp.scale, link.covariates = link.covariates, verbose =
verbose, ", " lincomb = lincomb, selection = selection, control.compute
= control.compute, ", " control.predictor = control.predictor,
control.family = control.family, ", " control.inla = control.inla,
control.fixed = control.fixed, ", " control.mode = control.mode,
control.expert = control.expert, ", " control.hazard = control.hazard,
control.lincomb = control.lincomb, ", " control.update =
control.update, control.lp.scale = control.lp.scale, ", "
control.pardiso = control.pardiso, only.hyperparam = only.hyperparam,
", " inla.call = inla.call, inla.arg = inla.arg, num.threads =
num.threads, ", " blas.num.threads = blas.num.threads, keep = keep,
working.directory = working.directory, ", " silent = silent, inla.mode
= inla.mode, safe = FALSE, debug = debug, ", " .parent.frame =
.parent.frame)")
Time used:
Pre = 0.515, Running = 6.61, Post = 0.251, Total = 7.37
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 7.851 0.017 7.818 7.851 7.884 7.851 0
weekendWeekend -0.049 18.258 -35.896 -0.050 35.768 -0.049 0
weekdayMonday -0.061 0.023 -0.106 -0.061 -0.015 -0.061 0
weekdaySaturday -0.024 18.258 -35.871 -0.025 35.793 -0.024 0
weekdaySunday -0.026 18.258 -35.873 -0.027 35.790 -0.026 0
weekdayThursday 0.025 0.023 -0.020 0.025 0.071 0.025 0
weekdayTuesday -0.019 0.023 -0.065 -0.019 0.027 -0.019 0
weekdayWednesday -0.053 0.023 -0.098 -0.053 -0.008 -0.053 0
Random effects:
Name Model
stock RW1 model
Model hyperparameters:
mean sd 0.025quant
size for the nbinomial observations (1/overdispersion) 5.23 0.100 5.04
Precision for stock 2.36 0.357 1.75
0.5quant 0.975quant mode
size for the nbinomial observations (1/overdispersion) 5.23 5.43 5.23
Precision for stock 2.32 3.15 2.26
Deviance Information Criterion (DIC) ...............: 81047.43
Deviance Information Criterion (DIC, saturated) ....: 155217.40
Effective number of parameters .....................: 125.20
Watanabe-Akaike information criterion (WAIC) ...: 81064.40
Effective number of parameters .................: 136.68
Marginal log-Likelihood: -42324.90
is computed
Posterior summaries for the linear predictor and the fitted values are computed
(Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
mod5 <- inla(users_mac ~
# weekend +
# weekday +
f(stock, model = "rw2", scale.model = TRUE, hyper = hyper.prec),
family = "nbinomial",
control.compute = list(dic= TRUE, waic = TRUE),
data = data)
Call:
c("inla.core(formula = formula, family = family, contrasts = contrasts,
", " data = data, quantiles = quantiles, E = E, offset = offset, ", "
scale = scale, weights = weights, Ntrials = Ntrials, strata = strata,
", " lp.scale = lp.scale, link.covariates = link.covariates, verbose =
verbose, ", " lincomb = lincomb, selection = selection, control.compute
= control.compute, ", " control.predictor = control.predictor,
control.family = control.family, ", " control.inla = control.inla,
control.fixed = control.fixed, ", " control.mode = control.mode,
control.expert = control.expert, ", " control.hazard = control.hazard,
control.lincomb = control.lincomb, ", " control.update =
control.update, control.lp.scale = control.lp.scale, ", "
control.pardiso = control.pardiso, only.hyperparam = only.hyperparam,
", " inla.call = inla.call, inla.arg = inla.arg, num.threads =
num.threads, ", " blas.num.threads = blas.num.threads, keep = keep,
working.directory = working.directory, ", " silent = silent, inla.mode
= inla.mode, safe = FALSE, debug = debug, ", " .parent.frame =
.parent.frame)")
Time used:
Pre = 0.521, Running = 7.01, Post = 0.175, Total = 7.7
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 7.823 0.008 7.806 7.823 7.839 7.823 0
Random effects:
Name Model
stock RW2 model
Model hyperparameters:
mean sd 0.025quant
size for the nbinomial observations (1/overdispersion) 5.114 0.097 4.923
Precision for stock 0.019 0.003 0.013
0.5quant 0.975quant
size for the nbinomial observations (1/overdispersion) 5.113 5.307
Precision for stock 0.019 0.027
mode
size for the nbinomial observations (1/overdispersion) 5.114
Precision for stock 0.018
Deviance Information Criterion (DIC) ...............: 81111.96
Deviance Information Criterion (DIC, saturated) ....: 155281.94
Effective number of parameters .....................: 57.13
Watanabe-Akaike information criterion (WAIC) ...: 81111.69
Effective number of parameters .................: 55.84
Marginal log-Likelihood: -45505.61
is computed
Posterior summaries for the linear predictor and the fitted values are computed
(Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
mod6 <- inla(users_mac ~
# weekend +
weekday +
f(stock, model = "rw2", scale.model = TRUE, hyper = hyper.prec),
family = "nbinomial",
control.compute = list(dic= TRUE, waic = TRUE),
data = data)
Call:
c("inla.core(formula = formula, family = family, contrasts = contrasts,
", " data = data, quantiles = quantiles, E = E, offset = offset, ", "
scale = scale, weights = weights, Ntrials = Ntrials, strata = strata,
", " lp.scale = lp.scale, link.covariates = link.covariates, verbose =
verbose, ", " lincomb = lincomb, selection = selection, control.compute
= control.compute, ", " control.predictor = control.predictor,
control.family = control.family, ", " control.inla = control.inla,
control.fixed = control.fixed, ", " control.mode = control.mode,
control.expert = control.expert, ", " control.hazard = control.hazard,
control.lincomb = control.lincomb, ", " control.update =
control.update, control.lp.scale = control.lp.scale, ", "
control.pardiso = control.pardiso, only.hyperparam = only.hyperparam,
", " inla.call = inla.call, inla.arg = inla.arg, num.threads =
num.threads, ", " blas.num.threads = blas.num.threads, keep = keep,
working.directory = working.directory, ", " silent = silent, inla.mode
= inla.mode, safe = FALSE, debug = debug, ", " .parent.frame =
.parent.frame)")
Time used:
Pre = 0.563, Running = 6.52, Post = 0.234, Total = 7.31
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 7.854 0.017 7.821 7.854 7.888 7.854 0
weekdayMonday -0.074 0.023 -0.120 -0.074 -0.029 -0.074 0
weekdaySaturday -0.074 0.025 -0.123 -0.074 -0.026 -0.074 0
weekdaySunday -0.079 0.025 -0.128 -0.079 -0.031 -0.079 0
weekdayThursday 0.024 0.023 -0.022 0.024 0.069 0.024 0
weekdayTuesday -0.020 0.023 -0.065 -0.020 0.026 -0.020 0
weekdayWednesday -0.056 0.023 -0.102 -0.056 -0.011 -0.056 0
Random effects:
Name Model
stock RW2 model
Model hyperparameters:
mean sd 0.025quant
size for the nbinomial observations (1/overdispersion) 5.14 0.098 4.945
Precision for stock 0.02 0.003 0.014
0.5quant 0.975quant
size for the nbinomial observations (1/overdispersion) 5.139 5.332
Precision for stock 0.019 0.027
mode
size for the nbinomial observations (1/overdispersion) 5.141
Precision for stock 0.019
Deviance Information Criterion (DIC) ...............: 81090.97
Deviance Information Criterion (DIC, saturated) ....: 155260.95
Effective number of parameters .....................: 63.03
Watanabe-Akaike information criterion (WAIC) ...: 81094.76
Effective number of parameters .................: 65.46
Marginal log-Likelihood: -45532.49
is computed
Posterior summaries for the linear predictor and the fitted values are computed
(Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
mod7 <- inla(users_mac ~
weekend +
weekday +
f(stock, model = "rw2", scale.model = TRUE, hyper = hyper.prec),
family = "nbinomial",
control.compute = list(dic= TRUE, waic = TRUE),
data = data)
Call:
c("inla.core(formula = formula, family = family, contrasts = contrasts,
", " data = data, quantiles = quantiles, E = E, offset = offset, ", "
scale = scale, weights = weights, Ntrials = Ntrials, strata = strata,
", " lp.scale = lp.scale, link.covariates = link.covariates, verbose =
verbose, ", " lincomb = lincomb, selection = selection, control.compute
= control.compute, ", " control.predictor = control.predictor,
control.family = control.family, ", " control.inla = control.inla,
control.fixed = control.fixed, ", " control.mode = control.mode,
control.expert = control.expert, ", " control.hazard = control.hazard,
control.lincomb = control.lincomb, ", " control.update =
control.update, control.lp.scale = control.lp.scale, ", "
control.pardiso = control.pardiso, only.hyperparam = only.hyperparam,
", " inla.call = inla.call, inla.arg = inla.arg, num.threads =
num.threads, ", " blas.num.threads = blas.num.threads, keep = keep,
working.directory = working.directory, ", " silent = silent, inla.mode
= inla.mode, safe = FALSE, debug = debug, ", " .parent.frame =
.parent.frame)")
Time used:
Pre = 0.538, Running = 6.88, Post = 0.24, Total = 7.66
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 7.854 0.017 7.821 7.854 7.888 7.854 0
weekendWeekend -0.052 18.257 -35.896 -0.052 35.763 -0.052 0
weekdayMonday -0.074 0.023 -0.120 -0.074 -0.029 -0.074 0
weekdaySaturday -0.023 18.257 -35.867 -0.023 35.792 -0.023 0
weekdaySunday -0.028 18.257 -35.872 -0.028 35.787 -0.028 0
weekdayThursday 0.024 0.023 -0.022 0.024 0.069 0.024 0
weekdayTuesday -0.020 0.023 -0.065 -0.020 0.026 -0.020 0
weekdayWednesday -0.056 0.023 -0.102 -0.056 -0.011 -0.056 0
Random effects:
Name Model
stock RW2 model
Model hyperparameters:
mean sd 0.025quant
size for the nbinomial observations (1/overdispersion) 5.14 0.098 4.946
Precision for stock 0.02 0.003 0.014
0.5quant 0.975quant
size for the nbinomial observations (1/overdispersion) 5.139 5.331
Precision for stock 0.019 0.027
mode
size for the nbinomial observations (1/overdispersion) 5.141
Precision for stock 0.019
Deviance Information Criterion (DIC) ...............: 81090.93
Deviance Information Criterion (DIC, saturated) ....: 155260.91
Effective number of parameters .....................: 63.00
Watanabe-Akaike information criterion (WAIC) ...: 81094.76
Effective number of parameters .................: 65.48
Marginal log-Likelihood: -45533.14
is computed
Posterior summaries for the linear predictor and the fitted values are computed
(Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')